package com.fau.fm.entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.GenericGenerator;
import org.json.simple.JSONAware;
import org.json.simple.JSONObject;
/**
 * 药品表
 * @author liy
 * @since 2014年7月24日,下午5:42:44
 */
@Entity
@Table(name = "medical_medicine")
public class MedicalMedicine implements Serializable, JSONAware {

	private static final long serialVersionUID = 3906679955811203440L;

	private String id;
	private String name;			// 名称
	private String serialNum;		// 编号
	private String unit;			// 单位
	private String valid;			// 有效期
	private BigDecimal price;		// 价格
	private String indications;		// 适应症
	private String aliases;			// 别名
	private String manufacturer;	// 生产厂家
	private String mainIngredient;	// 主要成分
	private String avoid;			// 禁忌
	private String dosage;			// 用法用量
	private String medicineSortId;	// 类别id
	private String medicineType;	// 产品类型（赠品、搭销、产品）
	private String medicineTypeName;	// 药品类型名称
	
	private String userId;			// 操作人id
	private Date createTime = new Date();		// 创建时间
	private Date updateTime = new Date();		// 更新时间
	private String hospitalId;					// 医院标识id
	
	
	@Id
	@GenericGenerator(name = "generator", strategy = "uuid.hex")
	@GeneratedValue(generator = "generator")
	@Column(name = "id", length = 32)
	public String getId() {
		return id;
	}
	
	public void setId(String id) {
		this.id = id;
	}

	@Column(name = "name", length = 255)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "serial_num", length = 50)
	public String getSerialNum() {
		return serialNum;
	}

	public void setSerialNum(String serialNum) {
		this.serialNum = serialNum;
	}
	
	@Column(name = "unit", length = 32)
	public String getUnit() {
		return unit;
	}

	public void setUnit(String unit) {
		this.unit = unit;
	}

	@Column(name = "valid", length = 30)
	public String getValid() {
		return valid;
	}

	public void setValid(String valid) {
		this.valid = valid;
	}
	
	@Column(name = "price", length = 11)
	public BigDecimal getPrice() {
		return price;
	}

	public void setPrice(BigDecimal price) {
		this.price = price;
	}

	@Column(name = "indications", length = 255)
	public String getIndications() {
		return indications;
	}

	public void setIndications(String indications) {
		this.indications = indications;
	}

	@Column(name = "aliases", length = 100)
	public String getAliases() {
		return aliases;
	}

	public void setAliases(String aliases) {
		this.aliases = aliases;
	}
	
	@Column(name = "manufacturer", length = 255)
	public String getManufacturer() {
		return manufacturer;
	}

	public void setManufacturer(String manufacturer) {
		this.manufacturer = manufacturer;
	}

	@Column(name = "main_ingredient", length = 255)
	public String getMainIngredient() {
		return mainIngredient;
	}

	public void setMainIngredient(String mainIngredient) {
		this.mainIngredient = mainIngredient;
	}

	@Column(name = "avoid", length = 500)
	public String getAvoid() {
		return avoid;
	}

	public void setAvoid(String avoid) {
		this.avoid = avoid;
	}

	@Column(name = "dosage", length = 255)
	public String getDosage() {
		return dosage;
	}

	public void setDosage(String dosage) {
		this.dosage = dosage;
	}

	@Transient
	public String getMedicineSortId() {
		return medicineSortId;
	}

	public void setMedicineSortId(String medicineSortId) {
		this.medicineSortId = medicineSortId;
	}
	
	@Column(name = "medicine_type", length = 20)
	public String getMedicineType() {
		return medicineType;
	}

	public void setMedicineType(String medicineType) {
		this.medicineType = medicineType;
	}
	
	@Transient
	public String getMedicineTypeName() {
		return medicineTypeName;
	}

	public void setMedicineTypeName(String medicineTypeName) {
		this.medicineTypeName = medicineTypeName;
	}

	@Column(name = "user_id", length = 32)
	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}
	
	@Column(name = "create_time")
	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Column(name = "update_time")
	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
	
	@Column(name="hospital_id",length = 32)
	public String getHospitalId() {
		return hospitalId;
	}

	public void setHospitalId(String hospitalId) {
		this.hospitalId = hospitalId;
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public String toJSONString() {
		JSONObject obj = new JSONObject();
		obj.put("id", id);
		obj.put("serialNum", serialNum);
		obj.put("serialNum1", serialNum);
		obj.put("name", name);
		obj.put("unit", unit);
		obj.put("aliases", aliases);
		obj.put("price", price);
		obj.put("manufacturer", manufacturer);
		obj.put("valid", this.valid);
		obj.put("indications", indications);
		obj.put("dosage", dosage);
		obj.put("mainIngredient", mainIngredient);
		obj.put("avoid", avoid);
		obj.put("medicineTypeName", medicineTypeName);
		
		return obj.toString();
	}
	
}
